<!--月考勤表-->
<template>
	<el-card>
		<el-form :inline="true" :model="state.queryForm" @keyup.enter="getDataList()">
			<el-form-item class="form-button-right">
				<el-button v-auth="'attendance:shift:save'" type="primary" @click="addOrUpdateHandle()">新增考勤组</el-button>
			</el-form-item>
			
			<el-form-item>
				<KeyQuery v-model="state.queryForm.keyword" @getDataList="getDataList()" />
			</el-form-item>
		</el-form>

		<el-table v-loading="state.dataListLoading" :data="state.dataList" border style="width: 100%" @selection-change="selectionChangeHandle">
			<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
			<el-table-column prop="id" label="主键" header-align="center" align="center" v-if="false"></el-table-column>

			<el-table-column prop="name" label="员工" header-align="center" align="center"></el-table-column>
			<el-table-column prop="number" label="工号" header-align="center" align="center"></el-table-column>
			<el-table-column prop="type" label="部门" header-align="center" align="center"></el-table-column>
			<el-table-column prop="startTime" label="职位" header-align="center" align="center"></el-table-column>

			<el-table-column prop="endTime" label="考勤组" header-align="center" align="center"></el-table-column>
			<el-table-column prop="isLate" label="应出勤天数(天)" header-align="center" align="center"></el-table-column>
			<el-table-column prop="isLate" label="实际出勤天数(天)" header-align="center" align="center"></el-table-column>
			<el-table-column prop="isLate" label="应出勤时长(小时)" header-align="center" align="center"></el-table-column>
			<el-table-column prop="isLate" label="实际出勤时长(小时)" header-align="center" align="center"></el-table-column>
			<el-table-column prop="isLate" label="迟到次数" header-align="center" align="center"></el-table-column>
			<el-table-column prop="isLate" label="早退次数" header-align="center" align="center"></el-table-column>
			<el-table-column prop="isLate" label="缺勤天数(天)" header-align="center" align="center"></el-table-column>

			<el-table-column label="操作" fixed="right" header-align="center" align="center" width="150">
				<template #default="scope">
					<el-button v-auth="'attendance:shift:update'" type="primary" link @click="addOrUpdateHandle(scope.row.id)">编辑</el-button>
					<el-button v-auth="'attendance:shift:delete'" type="primary" link @click="deleteBatchHandle(scope.row.id)">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination
			:current-page="state.page"
			:page-sizes="state.pageSizes"
			:page-size="state.limit"
			:total="state.total"
			layout="total, sizes, prev, pager, next, jumper"
			@size-change="sizeChangeHandle"
			@current-change="currentChangeHandle"
		>
		</el-pagination>

	</el-card>
</template>

<script setup lang="ts" name="AttendanceShiftIndex">
import { useCrud } from '@/hooks'
import { reactive, ref } from 'vue'
import { IHooksOptions } from '@/hooks/interface'

const state: IHooksOptions = reactive({
	dataListUrl: '/nb/shift/page',
	deleteUrl: '/nb/shift/delete',
	queryForm: {}
})

const addOrUpdateRef = ref()
const addOrUpdateHandle = (id?: number) => {
	addOrUpdateRef.value.init(id)
}

const findOrgStaffRef = ref()
const open = () => {
	console.info('1111')
	findOrgStaffRef.value.init()
}
const fn = () => {
	console.info('员工选择 -返现')
}

const { getDataList, selectionChangeHandle, sizeChangeHandle, currentChangeHandle, deleteBatchHandle } = useCrud(state)
</script>
